// import request from "@/utils/request.js";
// import Cache from "@/utils/cache.js"
import request from '@/config/minRequest.js'
const url = '/customer'
/**
 *  下单
 */
export function confirmOrder(data) {
  return request.post(url + `/v103/order/confirmOrder`, data);
}


/**
 *  下单（无规格）
 */
export function confirmOrderNoSku(data) {
  return request.post(url + `/v103/order/confirmOrderNoSku`, data);
}


/**
 *  查询订单详情
 */
export function getByOrderNumSalesman(orderNum) {
  return request.get(url + `/v103/order/getByOrderNumSalesman/${orderNum}`,);
}

/**
 *  业务员小程序-orderNum获取订单、券码详情
 */
export function getOrderDetailSalesmanByOrderNum(orderNum) {
  return request.get(url + `/v103/order/getOrderDetailSalesmanByOrderNum/${orderNum}`,);
}
// infoByUsageId
export function infoByUsageId(id) {
  return request.get(url + `/orderServiceProcess/open/infoByUsageId/${id}`,);
}

/**
 * 订单列表 
 */
export function getListBySalesman(data) {
  return request.post(url + `/v103/order/getListBySalesman`, data)
}

/**
 * 退款订单列表 
 */
export function getRefundListBySalesman(data) {
  return request.post(url + `/v103/order/getRefundListBySalesman`, data)
}

/**
 * 订单退款
 */
export function refundOrder(data) {
  return request.post(url + `/v103/order/refundOrderNew`, data)
}

/**
 * 取消订单
 */
export function cancelOrder(data) {
  return request.post(url + `/v103/order/cancelOrder`, data)
}


/**
 * 获取订单支付信息(在订单列表中针对只下单未付款的订单调用)
 */
export function getOrderPay(orderNum) {
  return request.post(url + `/v103/order/getOrderPay/${orderNum}`)
}
/**
 * 1.0.3获取协议或者客服电话
 */
export function getProtocolByCode(protocolCode) {
  return request.get(url + `/open/protocol/getProtocolByCode/${protocolCode}`)
}

/**
 * 获取领取记录
 */
export function getOrderReceiveList(data) {
  return request.post(url + `/v103/order/getOrderReceiveList`, data)
}

/**
 * 客户端小程序-小鸡获取支付参数 V-1.0.5
 */
export function chickenPay(data) {
  return request.post(url + `/placeChickenAnOrder`, data)
}
/**
 * 查询用户已经领取的优惠券 根据商品ID等
  POST /favorable_led/ticketHasBeenClaimed
  接口ID：119139404
  接口地址：https://app.apifox.com/link/project/1304401/apis/api-119139404
 */
export function ticketHasBeenClaimed(data) {
  return request.post(url + `/favorable_led/ticketHasBeenClaimed`, data)
}

//查询推荐给客户的健康管家
export function getRememberHealthManagered(data) {
  return request.get(url + `/healthManager/getRememberHealthManager`, data)
}

export function getTicketHasBeenClaimed(data) {
  return request.post(url + `/favorable_led/ticketHasBeenClaimedCount`, data)
}

/**
 * 查询优惠券对应的商品列表等
 */
export function favorableGoods(data) {
  return request.post(url + `/favorable_goods/correspondingProductOfCoupon`, data)
}
// 查询活动商品详情
export function getActiveGoodsById(activeGoodsId) {
  return request.get(url + `/active_goods_customer/open/getActiveGoodsById/${activeGoodsId}`)
}


/**
 * 查询分享的优惠券列表
 */
export function viewOneselfShareFavorable(data) {
  return request.post(url + `/favorable_info/viewOneselfShareFavorable`, data)
}

/**
 * 查询分享领取详情
 */
export function querySharedCouponsToReceive(data) {
  return request.post(url + `/favorable_led/querySharedCouponsToReceive`, data)
}


// 根据优惠券ID查询优惠券详情
export function getFavorableInfoById(favorableId) {
  return request.get(url + `/favorable_info/getFavorableInfoById/${favorableId}`)
}

//判断该优惠券该客户是否可以领取
export function judgeCouponsCustomersCanClaim(favorableId) {
  return request.get(url + `/favorable_led/judgeCouponsCustomersCanClaim/${favorableId}`)
}

//领取优惠券
export function getACoupon(favorableId) {
  return request.get(url + `/favorable_led/getACoupon/${favorableId}`)
}

// 上传 优惠券ID 客户ID 到 Redis
export function storeInRedis(data) {
  return request.post(url + `/favorable_info/storeInRedis?favorableId=${data.favorableId}&userId=${data.userId}`);
}

/**
 * 获取客户小程序二维码-前端传 appID
 */
export function getMiniCodeByAppId(data) {
  return request.post(url + `/wechat/getMiniCodeByAppId`, data)
}

//存储数据到Redis
export function getGoodsRedis(data) {
  return request.post(url + `/redis/storage/store`, data)
}

//从Redis获取数据
export function getGoodsGet(data) {
  return request.post(url + `/redis/storage/get`, data)
}

// 分享优惠券
export function shareFavorable(data) {
  return request.post(url + `/favorable_led/shareFavorable?favorableId=${data.favorableId}&wantShareNum=${data.wantShareNum}`);
}

// 分享优惠券-转发
export function shareFavorableType(data) {
  return request.post(url + `/favorable_led/transfer`, data);
}

// 解析 核销优惠券Redis Key
export function analyzeACouponRedisKey(data) {
  return request.post(url + `/favorable_led/analyzeACouponRedisKey?redisKey=${data.redisKey}`);
}

// 分享优惠券
// export function cancelACoupon(data) {
// 	return request.post(url + `/favorable_led/cancelACoupon?favorableId=${data.favorableId}&userId=${data.userId  }`);
// }
export function cancelACoupon(data) {
  return request.post(url + `/favorable_led/cancelACouponRedis?redisKey=${data.redisKey}`);
}

//创建优惠券
export function createCoupon(data) {
  return request.post(url + `/favorable_info/add`, data);
}

//创建优惠券列表
export function createCouponList(data) {
  return request.post(url + `/favorable_info/list`, data);
}

//优惠券活动-列表
export function favorableActivityList(data) {
  return request.post(url + `/favorableActivity/list`, data);
}
//编辑优惠券
export function updateCoupon(data) {
  return request.post(url + `/favorable_info/update`, data);
}

// 删除创建的优惠券
export function deleteCoupon(id) {
  return request.get(url + `/favorable_info/delete/${id}`)
}

// 优惠券编辑详情
export function createCouponDetail(favorableId) {
  return request.get(url + `/favorable_info/getFavorableInfoById/${favorableId}`)
}

// 获取领取的优惠券关联的商品列表-v2.0
export function getLedGoodsList(id, data) {
  // return request.post(url + `/favorable_led/getLedGoodsList/${id}`,data)
  return request.post(url + `/favorable_info/getGoodsList/${id}`, data)
}

// 短信服务
export function sendVerificationCode(phone, data) {
  return request.get(url + `/sms/sendVerificationCode/${phone}`, data)
}

// 优惠券活动-撤销活动
export function cancelActivity(uniqueId) {
  return request.post(url + `/favorableActivity/cancelActivity/${uniqueId}`)
}

//查询客户的各商品服务总数以及使用次数
export function listGoodsServiceRecord(data) {
  return request.post(url + `/goods_service_record/listGoodsServiceRecord`, data);
}

// 订单明细使用记录
export function orderGoodsUsage(data) {
  return request.get(url + `/orderGoodsUsage/list`, data)
}

// 申请退款
export function orderRefund(orderNum) {
  return request.get(url + `/order_refund/refund/${orderNum}`)
}

//使用商品服务
export function useGoods(data) {
  return request.post(url + `/orderGoodsUsage/useGoods`, data);
}